{extend name="layout/main" /}

{block name="header"}

{/block}

{block name="content"}
<!--<link rel="stylesheet" href="http://cdn.staticfile.org/webuploader/0.1.5/webuploader.css">-->
<!--<script type="text/javascript" src='http://cdn.staticfile.org/webuploader/0.1.5/webuploader.min.js'></script>-->
<style type="text/css">
    /*body{*/
    /*overflow-x:hidden;*/
    /*overflow-y: auto;*/
    /*width:100%;*/
    /*}*/
    /*.table{*/
    /*display: block;*/
    /*overflow-y: hidden;*/
    /*overflow-x: auto;*/
    /*}*/
    /*.form-control{*/
    /*width: auto;*/
    /*}*/

</style>


<section class="panel">
    <header class="panel-heading">
        <h4>用户等级配置</h4>
    </header>
    <div class="panel-body" style="padding-bottom: 50px">
        <table class="table table-bordered table-striped no-margin">
            <thead>
            <tr>
                <th class="text-center">序号</th>
                <th class="text-center">用户等级</th>
                <th class="text-center">个人消费</th>
                <th class="text-center">直推普卡会员</th>
                <th class="text-center">直推银卡会员</th>
                <th class="text-center">直推金卡会员</th>
                <th class="text-center">团队业绩（小区业绩）%</th>
                <th class="text-center">直推奖励%</th>
                <th class="text-center">间推奖励%</th>
                <th class="text-center">交易手续费奖励（直推）%</th>
                <th class="text-center">平台交易手续费加权平均%</th>
                <th class="text-center">操作</th>
            </tr>
            </thead>
            <tbody>
            {foreach $list as $key=>$config}
            <tr>
                <td class="text-center" style="vertical-align: middle; ">{$key+1}</td>
                <td class="text-center" style="vertical-align: middle; ">
                    {$user->getOneLevel($config->level)}

                </td>
                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_pay_money_{$config['id']}" style="text-align: center" class="form-control"
                           value="{$config['pay_money']}">
                </td>

                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_level1_{$config['id']}" style="text-align: center" class="form-control"
                           value="{$config['level1']}">
                </td>
                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_level2_{$config['id']}" style="text-align: center" class="form-control"
                           value="{$config['level2']}">
                </td>
                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_level3_{$config['id']}" style="text-align: center" class="form-control"
                           value="{$config['level3']}">
                </td>

                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_team_ratio_{$config['id']}" style="text-align: center" class="form-control"
                           value="{$config['team_ratio']}">
                </td>
                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_direct_{$config['id']}" style="text-align: center" class="form-control"
                           value="{$config['direct']}">
                </td>

                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_indirect_{$config['id']}" style="text-align: center"
                           class="form-control"
                           value="{$config['indirect']}">
                </td>
                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_trade_{$config['id']}" style="text-align: center"
                           class="form-control"
                           value="{$config['trade']}">
                </td>
                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_platform_{$config['id']}" style="text-align: center"
                           class="form-control"
                           value="{$config['platform']}">
                </td>
                <td class="text-center" style="vertical-align: middle; ">
                    <a onclick="updateConfigCopy(this)"
                       data-level="{$config['level']}"
                       data-pay_money="{$config['pay_money']}"
                       data-level1="{$config['level1']}"
                       data-level2="{$config['level2']}"
                       data-level3="{$config['level3']}"
                       data-team_ratio="{$config['team_ratio']}"
                       data-direct="{$config['direct']}"
                       data-indirect="{$config['indirect']}"
                       data-trade="{$config['trade']}"
                       data-trade="{$config['platform']}"
                       id-data="{$config['id']}" class="btn btn-xs btn-primary">确认修改</a>
                </td>

            </tr>
            <!-- {/if} -->
            {/foreach}
            </tbody>
        </table>

    </div>
</section>


{/block}

{block name="footer"}

<script>

    function updateConfigCopy(e) {
        var id = $(e).attr('id-data');
        var level = $(e).attr('data-level');

        var pay_money1 = $(e).attr('data-pay_money');
        var pay_money = $('#_pay_money_' +id).val();

        var level11 = $(e).attr('data-level1');
        var level1 = $('#_level1_' + id).val();

        var level21 = $(e).attr('data-level2');
        var level2 = $('#_level2_' + id).val();

        var level31 = $(e).attr('data-level3');
        var level3 = $('#_level3_' + id).val();

        var team_ratio1 = $(e).attr('data-team_ratio');
        var team_ratio = $('#_team_ratio_' + id).val();

        var direct1 = $(e).attr('data-direct');
        var direct = $('#_direct_' + id).val();

        var indirect1 = $(e).attr('data-indirect');
        var indirect = $('#_indirect_' + id).val();

        var trade1 = $(e).attr('data-trade');
        var trade = $('#_trade_' + id).val();

        var platform1 = $(e).attr('data-platform');
        var platform = $('#_platform_' + id).val();
        console.log({
            id: id,
            level: level,
            pay_money:pay_money,
            level1:level1,
            level2:level2,
            level3:level3,
            team_ratio:team_ratio,
            direct:direct,
            indirect:indirect,
            trade:trade,
            platform:platform,
        });
        $.post("{:url('packageSetsave')}", {
            id: id,
            level: level,
            pay_money:pay_money,
            level1:level1,
            level2:level2,
            level3:level3,
            team_ratio:team_ratio,
            direct:direct,
            indirect:indirect,
            trade:trade,
            platform:platform,
        }, function (data) {
            if (data.code == 1) {
                main.waringAlert(data.message);
            } else {
                main.waringAlert(data.message);
                window.location.reload();
            }
        }, 'json')
    }




</script>


</script>
{/block}
